home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 18054 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: helium.einet.net!usenet
  2. From: arisco@tradewave.com (John Arisco)
  3. Newsgroups: comp.os.ms-windows.programmer.tools.misc,comp.os.ms-windows.programmer.win32,comp.os.ms-windows.programmer.misc,comp.lang.c++
  4. Subject: Re: [Q] Why doesn't this compile?
  5. Date: Thu, 18 Apr 1996 18:15:30 GMT
  6. Organization: TradeWave Corporation
  7. Message-ID: <4l60lp$ot8@helium.einet.net>
  8. References: <317523C0.5042@eps.agfa.be> <4l3cpv$l74@helium.einet.net> <3175EAD9.52CD@eps.agfa.be>
  9. NNTP-Posting-Host: platinum.einet.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. I   wrote:
  13. >> You cannot call a non-static member function without specifying
  14. >> an object.  The way you've written this, there is no way for B::L::f()
  15. >> to set its "this" pointer.
  16.  
  17. Rob Stewart <stew@datalytics.com> wrote:
  18. > That's nonsensical.  We're talking class declarations here.  
  19. > B::L::f is a non-static member function of B::L, so it has a
  20. > this pointer.
  21.  
  22. Although Rob is correct, what I meant to say was that there is
  23. no way to set the "this" pointer for B::L::f()'s call to  A::L::f().
  24. (In other words, when I said "its", I meant "A::L::f()'s", not "its
  25. own".)  Unfortunately, I was still wrong.
  26.  
  27. Chris Hill <hillca@cs.purdue.edu> wrote:
  28. > A::L::f requires that f is a static function.  Which A object do
  29. > you expect the compiler to call f for?
  30.  
  31. This is what I meant in my first post.  However, it is wrong,
  32. because A::L is a base class of B::L, and the syntax for a
  33. method in a derived class to call a function in its base class
  34. is  baseclassname::f().  When viewed in light of this, the call
  35. to A::L::f() definitely has a valid "this" pointer.
  36.  
  37. Ranko Orlic <rorlic@eps.agfa.be> responded to Chris:
  38. > According to me you did not understand the error message
  39. > completely. The compiler incorrectly thinks that B::L::f is a
  40. > static member function.
  41.  
  42. I don't think so.  I think the compiler made the same error that
  43. I made.  It didn't recognize that B::L::f() was calling a function
  44. in it's own base class, so it assumed that A::L::f() was a static
  45. function call, and it barfed because A::L::f() was not declared
  46. static.
  47.  
  48. Ranko goes on to say:
  49. > The code IS perfectly legal. The compiler simply does not
  50. > work properly.
  51.  
  52. Yes, I now agree with Rob and Ranko that this is a compiler
  53. bug and not a coding error. 
  54.  
  55. Sometimes you get the bear, sometimes the bear gets you.
  56.  
  57. |  John Arisco   <arisco@tradewave.com>
  58. |  TradeWave Corp, 3636 Executive Center Dr, #100, Austin, TX 78731
  59. |  Voice: (512) 433-5313     Main: 433-5300     Fax: 433-5303
  60.  
  61.  
  62.  
  63.